home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / make / icmake-6.000 / icmake-6 / icmake / rss / error.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-08  |  1.1 KB  |  54 lines

  1. /*
  2. \funcref{error}{void error (\params, ...)}
  3.     {
  4.         {char} {*fmt} {format string}
  5.     }
  6.     {}
  7.     {}
  8.     {}
  9.     {error.c}
  10.     {
  11.         Prints an error message, defined by the format string and (optional)
  12.         following arguments, to {\em stderr}. If {\em stdout} is redirected,
  13.         the message is printed to {\em stdout} too. Then the global {\em int}
  14.         variable {\em error\_occurred} is incremented to reflect an error (a
  15.         cleanup function, attached by {\em atexit()},
  16.         may inspect this value and take appropriate action).
  17.  
  18.         After this, the program is terminated with an exit value 1.
  19.     }
  20. */
  21.  
  22. #include "icrssdef.h"
  23.  
  24. int
  25.     error_occurred = 0;
  26.  
  27. #ifdef _PROTOTYPES
  28. void error (char *fmt, ...)
  29. #else
  30. void error (fmt MARG)
  31. char *fmt;
  32. #endif
  33. {
  34.     va_list
  35.         args;
  36.  
  37.     fflush (stdout);
  38.     fflush (stderr);
  39.  
  40.     va_start (args, fmt);
  41.     vfprintf (stderr, fmt, args);
  42.     fputc ('\n', stderr);
  43.  
  44.     if (! isatty (fileno (stdout)))
  45.     {
  46.         va_start (args, fmt);
  47.         vprintf (fmt, args);
  48.         putchar ('\n');
  49.     }
  50.  
  51.     error_occurred++;
  52.     exit (1);
  53. }
  54.